package com.dengyuanke.admin.controller;


import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.dengyuanke.common.result.JsonResult;
import com.dengyuanke.entity.Orders;
import com.dengyuanke.entity.OrdersDetails;
import com.dengyuanke.service.IOrdersDetailsService;
import com.dengyuanke.service.IOrdersService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 * 订单表 前端控制器
 * </p>
 *
 * @author dengyuanke
 * @since 2017-11-07
 */
@Api(tags = "订单相关API")
@RestController
public class OrdersController {

    @Autowired
    private IOrdersService ordersService;

    @Autowired
    private IOrdersDetailsService ordersDetailsService;


    /**
     * 获取全部订单
     * @return
     */
    @ApiOperation(value = "获得全部订单",notes = "无需传入参数")
    public JsonResult getAllOrders(){
        List<Orders> orders = ordersService.selectList(null);
        return JsonResult.renderSuccess(orders);
    }

    /**
     * 查看订单详情
     * @param ordersId
     * @return
     */
    @ApiOperation(value = "查看订单详情",notes = "传入订单id")
    @ApiParam(value="订单id",name="ordersId",required=true)
    public JsonResult getOrderDetails(String ordersId){
        List<OrdersDetails> ordersDetails = ordersDetailsService.selectList(new EntityWrapper<OrdersDetails>().eq("orders_id", ordersId));
        return  JsonResult.renderSuccess(ordersDetails);
    }
	
}
